package com.cgy.repository;


import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.cgy.entity.ResStatistics;

public interface ResStatisricsRepository extends JpaRepository<ResStatistics, Integer>,JpaSpecificationExecutor<ResStatistics>{
	@Query(value = "delete from ResStatistics WHERE rid=?1")  
    @Modifying 
    @Transactional 
	Integer deleteResStatistics(Integer rid);
	@Query(value = "update  ResStatistics set rUserTimes = rUserTimes+1 WHERE zid=?1")  
    @Modifying 
    @Transactional  
	Integer upByZid(Integer zid);
	//根据月份和资源室id查询数据
	@Query(value = "select sum(r_user_times) from  res_statistics  where  month=?1 and zid = ?2",nativeQuery=true)
	Integer findTest(String month,Integer rid);
	//根据月份和资源室id修改访问次数
	@Query(value = "update  res_statistics set r_user_times=r_user_times+1 where zid = ?1 and  month=?2 ",nativeQuery=true)
	Integer upCiShu(Integer zid,String month);
	
}
